//    请求并发   ES6
export const concurrencyRequest = (callBack = []) => {
	return Promise.all([...callBack]).then(res => {
		return res
	})
}
//    请求并发   ES7
export let func = async (callback = []) => {
	let arr = []
	for (let i = 0; i < callback.length; i++) {
		arr.push(await callback[i])
	};
	return arr
}
//   数字千位分隔符且保留两位小数
/*
   value : number    
   return: string  '1,000.00'
*/
export function ThousandAndDecimal(num) {
	return num ? (num.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,')) : ('0.00')
}
//   判断 H5环境
export let getEnv = () => {
	let env = location.hostname.toLowerCase(),
		port = location.port;
	let serviceUrl = null;
	let envVersion = {
		// https://ydhb-test.yidubianli.com
		'development': 'https://ydhb-test.yidubianli.com', // 测试环境
		'production': {
			"trial": 'https://ydhb-test.yidubianli.com', // 测试环境
			"release": 'https://ydhb-api.yidubianli.com', // 生产环境
		}
	};
	const ENV = process.env.NODE_ENV;
	//    本地 打包
	if (port && ENV === 'production') {
		serviceUrl = envVersion['development']
		return {
			serviceUrl
		};
	}
	//   线上打包 test prd
	if (ENV === 'production') {
		serviceUrl = env.includes('test') ? envVersion[ENV]["trial"] : (envVersion[ENV]["release"]);
	}
	//  dev
	if (ENV === 'development') serviceUrl = envVersion[ENV];
	return {
		serviceUrl
	}
}